GtkSearchEntry: Don't wait for timeout when emptying
authorBastien Nocera <hadess@hadess.net>
Tue, 21 May 2013 16:31:10 +0000 (18:31 +0200)
committerBastien Nocera <hadess@hadess.net>
Thu, 23 May 2013 18:53:30 +0000 (20:53 +0200)
When the text entry gets cleared, emit the "changed" signal
straight away. This avoids a lag when dismissing a search.

https://bugzilla.gnome.org/show_bug.cgi?id=700787

gtk/gtksearchentry.c

index b79705b3eee5ad24ca0f90d6af420cbc0e37e2d9..c29faab000d028efc4eb74bed46eb72e516e5420 100644 (file)
@@ -124,6 +124,7 @@ search_entry_changed_cb (GtkSearchEntry *entry,
   GtkSearchEntryPrivate *priv = GET_PRIV (entry);
   const char *str, *icon_name;
   gboolean active;
+  gboolean cleared = FALSE;
 
   /* Update the icons first */
   str = gtk_entry_get_text (GTK_ENTRY (entry));
@@ -132,6 +133,7 @@ search_entry_changed_cb (GtkSearchEntry *entry,
     {
       icon_name = NULL;
       active = FALSE;
+      cleared = TRUE;
     }
   else
     {
@@ -153,6 +155,11 @@ search_entry_changed_cb (GtkSearchEntry *entry,
   if (priv->in_timeout)
     return;
 
+  /* Don't emit the signal in a timeout if we've cleared
+   * the entry, we don't want a delay */
+  if (cleared)
+    return;
+
   /* Queue up the timeout */
   reset_timeout (entry);
   g_signal_stop_emission_by_name (entry, "changed");